package ltd.newbee.mall.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页
 * @param <T>
 */
@Data
public class PageResult<T> implements Serializable {
    @Schema(description = "总记录数")
    private int totalCount;

    @Schema(description = "每页记录数")
    private int pageSize;

    @Schema(description = "总页数")
    private int totalPage;

    @Schema(description = "当前页数")
    private int currPage;

    @Schema(description = "列表数据")
    private List<T> list;

    public PageResult(List<T> list,int totalCount,int pageSize,int currPage){
        this.list = list;
        this.totalCount = totalCount;
        this.pageSize = pageSize;
        this.currPage = currPage;
        this.totalPage = (int) Math.ceil((double) totalCount / pageSize);
    }
}
